package cn.edu.lzu.dao;

import cn.edu.lzu.entity.City;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface CityMapper {

    //选出所有的省级记录
    @Select("select * from city where level=0")
    List<City> selAllProvince();

    //选出所有的市级记录
    @Select("select * from city where level=1")
    List<City> selAllCity();

    //选出所有的县级记录
    @Select("select * from city where level=2")
    List<City> selAllCounty();

    //根据省的编号选出所有该省的市级记录
    @Select("select * from city where parent_id=#{provinceId} and level=1")
    List<City> selAllCityByProvinceId(long provinceId);

    //根据市的编号选出所有该市的县级记录
    @Select("select * from city where parent_id=#{cityId} and level=2")
    List<City> selAllCountyByCityId(long cityId);

    @Select("select * from city where city_id=#{id}")
    City selSpecificCityById(long id);
}
